﻿<UserControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="Majesty_of_Omega.GUI.Controls.Panel"
    MinWidth="100" Height="Auto">
  <UserControl.Resources>
    <ControlTemplate x:Key="PanelExpanderControlTemplate" TargetType="{x:Type Expander}">
      <Border x:Name="BorderTemplate" SnapsToDevicePixels="True" Background="{DynamicResource InfoTitleBackgroundBrush}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="8,8,8,8">
        <DockPanel>
          <ToggleButton Margin="1,1,1,1" MinHeight="0" MinWidth="0" x:Name="HeaderSite" Content="{TemplateBinding Header}" ContentTemplate="{TemplateBinding HeaderTemplate}" FontFamily="{TemplateBinding FontFamily}" FontSize="{TemplateBinding FontSize}" FontStretch="{TemplateBinding FontStretch}" FontStyle="{TemplateBinding FontStyle}" FontWeight="{TemplateBinding FontWeight}" Foreground="{TemplateBinding Foreground}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" Padding="{TemplateBinding Padding}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" IsChecked="{Binding Path=IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" DockPanel.Dock="Top">
            <ToggleButton.FocusVisualStyle>
              <Style>
                <Setter Property="Control.Template">
                  <Setter.Value>
                    <ControlTemplate>
                      <Border>
                        <Rectangle SnapsToDevicePixels="True" Stroke="#FF000000" StrokeDashArray="1 2" StrokeThickness="1" Margin="0,0,0,0"/>
                      </Border>
                    </ControlTemplate>
                  </Setter.Value>
                </Setter>
              </Style>
            </ToggleButton.FocusVisualStyle>
            <ToggleButton.Style>
              <Style TargetType="{x:Type ToggleButton}">
                <Setter Property="Template">
                  <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ToggleButton}">
                      <Border Padding="{TemplateBinding Padding}">
                        <Grid SnapsToDevicePixels="False" Background="#00FFFFFF">
                          <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="19"/>
                            <ColumnDefinition Width="*"/>
                          </Grid.ColumnDefinitions>
                          <Ellipse  Stroke="#FFA9A9A9" HorizontalAlignment="Center" x:Name="circle" VerticalAlignment="Center" Width="19" Height="19"/>
                          <Ellipse Visibility="Hidden"  HorizontalAlignment="Center" x:Name="shadow" VerticalAlignment="Center" Width="17" Height="17"/>
                          <Path SnapsToDevicePixels="False" Stroke="#FF666666" StrokeThickness="2" HorizontalAlignment="Center" x:Name="arrow" VerticalAlignment="Center" Data="M1,1.5L4.5,5 8,1.5"/>
                          <ContentPresenter SnapsToDevicePixels="True" HorizontalAlignment="Center" Margin="4,0,0,0" VerticalAlignment="Center" Grid.Column="1" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" RecognizesAccessKey="True"/>
                        </Grid>
                      </Border>
                      <ControlTemplate.Triggers>
                        <Trigger Property="IsChecked" Value="True">
                          <Setter Property="Data" TargetName="arrow" Value="M1,4.5L4.5,1 8,4.5"/>
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True">
                          <Setter Property="Stroke" TargetName="circle" Value="#FF666666"/>
                          <Setter Property="Stroke" TargetName="arrow" Value="#FF222222"/>
                          <Setter Property="Visibility" TargetName="shadow" Value="Visible"/>
                        </Trigger>
                      </ControlTemplate.Triggers>
                    </ControlTemplate>
                  </Setter.Value>
                </Setter>
              </Style>
            </ToggleButton.Style>
          </ToggleButton>
          <ContentPresenter Focusable="False" Visibility="Collapsed" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" x:Name="ExpandSite" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" DockPanel.Dock="Bottom" OpacityMask="{DynamicResource PanelBackgroundBrush}"/>
        </DockPanel>
      </Border>
      <ControlTemplate.Triggers>
        <Trigger Property="IsExpanded" Value="True">
          <Setter Property="Visibility" TargetName="ExpandSite" Value="Visible"/>
        </Trigger>
        <Trigger Property="ExpandDirection" Value="Right">
          <Setter Property="DockPanel.Dock" TargetName="ExpandSite" Value="Right"/>
          <Setter Property="DockPanel.Dock" TargetName="HeaderSite" Value="Left"/>
          <Setter Property="Style" TargetName="HeaderSite">
            <Setter.Value>
              <Style TargetType="{x:Type ToggleButton}">
                <Setter Property="Template">
                  <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ToggleButton}">
                      <Border Padding="{TemplateBinding Padding}">
                        <Grid SnapsToDevicePixels="False" Background="#00FFFFFF">
                          <Grid.RowDefinitions>
                            <RowDefinition Height="19"/>
                            <RowDefinition Height="*"/>
                          </Grid.RowDefinitions>
                          <Grid>
                            <Grid.LayoutTransform>
                              <TransformGroup>
                                <RotateTransform Angle="-90"/>
                              </TransformGroup>
                            </Grid.LayoutTransform>
                            <Ellipse Stroke="#FFA9A9A9" HorizontalAlignment="Center" x:Name="circle" VerticalAlignment="Center" Width="19" Height="19"/>
                            <Ellipse Visibility="Hidden"  HorizontalAlignment="Center" x:Name="shadow" VerticalAlignment="Center" Width="17" Height="17"/>
                            <Path SnapsToDevicePixels="False" Stroke="#FF666666" StrokeThickness="2" HorizontalAlignment="Center" x:Name="arrow" VerticalAlignment="Center" Data="M1,1.5L4.5,5 8,1.5"/>
                          </Grid>
                          <ContentPresenter SnapsToDevicePixels="True" HorizontalAlignment="Center" Margin="0,4,0,0" VerticalAlignment="Top" Grid.Row="1" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" RecognizesAccessKey="True"/>
                        </Grid>
                      </Border>
                      <ControlTemplate.Triggers>
                        <Trigger Property="IsChecked" Value="True">
                          <Setter Property="Data" TargetName="arrow" Value="M1,4.5L4.5,1 8,4.5"/>
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True">
                          <Setter Property="Stroke" TargetName="circle" Value="#FF666666"/>
                          <Setter Property="Stroke" TargetName="arrow" Value="#FF222222"/>
                          <Setter Property="Visibility" TargetName="shadow" Value="Visible"/>
                        </Trigger>
                      </ControlTemplate.Triggers>
                    </ControlTemplate>
                  </Setter.Value>
                </Setter>
              </Style>
            </Setter.Value>
          </Setter>
        </Trigger>
        <Trigger Property="ExpandDirection" Value="Up">
          <Setter Property="DockPanel.Dock" TargetName="ExpandSite" Value="Top"/>
          <Setter Property="DockPanel.Dock" TargetName="HeaderSite" Value="Bottom"/>
          <Setter Property="Style" TargetName="HeaderSite">
            <Setter.Value>
              <Style TargetType="{x:Type ToggleButton}">
                <Setter Property="Template">
                  <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ToggleButton}">
                      <Border Padding="{TemplateBinding Padding}">
                        <Grid SnapsToDevicePixels="False" Background="#00FFFFFF">
                          <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="19"/>
                            <ColumnDefinition Width="*"/>
                          </Grid.ColumnDefinitions>
                          <Grid>
                            <Grid.LayoutTransform>
                              <TransformGroup>
                                <RotateTransform Angle="180"/>
                              </TransformGroup>
                            </Grid.LayoutTransform>
                            <Ellipse Stroke="#FFA9A9A9" HorizontalAlignment="Center" x:Name="circle" VerticalAlignment="Center" Width="19" Height="19"/>
                            <Ellipse Visibility="Hidden" HorizontalAlignment="Center" x:Name="shadow" VerticalAlignment="Center" Width="17" Height="17"/>
                            <Path SnapsToDevicePixels="False" Stroke="#FF666666" StrokeThickness="2" HorizontalAlignment="Center" x:Name="arrow" VerticalAlignment="Center" Data="M1,1.5L4.5,5 8,1.5"/>
                          </Grid>
                          <ContentPresenter SnapsToDevicePixels="True" HorizontalAlignment="Left" Margin="4,0,0,0" VerticalAlignment="Center" Grid.Column="1" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" RecognizesAccessKey="True"/>
                        </Grid>
                      </Border>
                      <ControlTemplate.Triggers>
                        <Trigger Property="IsChecked" Value="True">
                          <Setter Property="Data" TargetName="arrow" Value="M1,4.5L4.5,1 8,4.5"/>
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True">
                          <Setter Property="Stroke" TargetName="circle" Value="#FF666666"/>
                          <Setter Property="Stroke" TargetName="arrow" Value="#FF222222"/>
                          <Setter Property="Visibility" TargetName="shadow" Value="Visible"/>
                        </Trigger>
                      </ControlTemplate.Triggers>
                    </ControlTemplate>
                  </Setter.Value>
                </Setter>
              </Style>
            </Setter.Value>
          </Setter>
        </Trigger>
        <Trigger Property="ExpandDirection" Value="Left">
          <Setter Property="DockPanel.Dock" TargetName="ExpandSite" Value="Left"/>
          <Setter Property="DockPanel.Dock" TargetName="HeaderSite" Value="Right"/>
          <Setter Property="Style" TargetName="HeaderSite">
            <Setter.Value>
              <Style TargetType="{x:Type ToggleButton}">
                <Setter Property="Template">
                  <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ToggleButton}">
                      <Border Padding="{TemplateBinding Padding}">
                        <Grid SnapsToDevicePixels="False" Background="#00FFFFFF">
                          <Grid.RowDefinitions>
                            <RowDefinition Height="19"/>
                            <RowDefinition Height="*"/>
                          </Grid.RowDefinitions>
                          <Grid>
                            <Grid.LayoutTransform>
                              <TransformGroup>
                                <RotateTransform Angle="90"/>
                              </TransformGroup>
                            </Grid.LayoutTransform>
                            <Ellipse Stroke="#FFA9A9A9" HorizontalAlignment="Center" x:Name="circle" VerticalAlignment="Center" Width="19" Height="19"/>
                            <Ellipse Visibility="Hidden" HorizontalAlignment="Center" x:Name="shadow" VerticalAlignment="Center" Width="17" Height="17"/>
                            <Path SnapsToDevicePixels="False" Stroke="#FF666666" StrokeThickness="2" HorizontalAlignment="Center" x:Name="arrow" VerticalAlignment="Center" Data="M1,1.5L4.5,5 8,1.5"/>
                          </Grid>
                          <ContentPresenter SnapsToDevicePixels="True" HorizontalAlignment="Center" Margin="0,4,0,0" VerticalAlignment="Top" Grid.Row="1" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" RecognizesAccessKey="True"/>
                        </Grid>
                      </Border>
                      <ControlTemplate.Triggers>
                        <Trigger Property="IsChecked" Value="True">
                          <Setter Property="Data" TargetName="arrow" Value="M1,4.5L4.5,1 8,4.5"/>
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True">
                          <Setter Property="Stroke" TargetName="circle" Value="#FF666666"/>
                          <Setter Property="Stroke" TargetName="arrow" Value="#FF222222"/>
                          <Setter Property="Visibility" TargetName="shadow" Value="Visible"/>
                        </Trigger>
                      </ControlTemplate.Triggers>
                    </ControlTemplate>
                  </Setter.Value>
                </Setter>
              </Style>
            </Setter.Value>
          </Setter>
        </Trigger>
        <Trigger Property="IsEnabled" Value="False">
          <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
        </Trigger>
      </ControlTemplate.Triggers>
    </ControlTemplate>
  </UserControl.Resources>
  <Expander x:Name="ExpanderTitle" Header="ExpanderTest" Width="Auto" Height="Auto" IsExpanded="True" BorderBrush="#FFFFFFFF" BorderThickness="1,1,1,1" Template="{DynamicResource PanelExpanderControlTemplate}">
    <Border x:Name="BorderContent">
      <Grid Name="ContentPlaceHolder" >
      	<Grid.ColumnDefinitions>
      		<ColumnDefinition Width="0.292*"/>
      		<ColumnDefinition Width="0.708*"/>
      	</Grid.ColumnDefinitions>
      </Grid>
    </Border>
  </Expander>
</UserControl>
